package health.lm.com.home.activity;

import android.os.Bundle;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.lm.sjy.titlebar.widget.CommonTitleBar;
import com.vondear.rxtool.RxTimeTool;
import com.zzhoujay.richtext.RichText;

import java.util.Date;

import butterknife.BindView;
import health.lm.com.component_base.base.mvp.activity.XActivity;
import health.lm.com.home.R;
import health.lm.com.home.R2;
import health.lm.com.home.entity.NoticeDetailEntity;
import health.lm.com.home.model.HomeModel;
import health.lm.com.network.callback.SimpleCallBack;
import health.lm.com.router.ARouterConstant;

/**
 * Created by Android Studio .
 * Project：hlian health.lm.com.home.activity
 * Date：2019/8/21 17:55
 * Introduce：公告详情
 */
@Route(path = ARouterConstant.NoticesDetailActivity)
public class NoticesDetailActivity extends XActivity {
    @Autowired
    public int _id;
    @BindView(R2.id.title_bar)
    CommonTitleBar mTitleBar;
    @BindView(R2.id.textView11)
    TextView mTextView11;
    @BindView(R2.id.textView17)
    TextView mTextView17;
    @BindView(R2.id.textView18)
    TextView mTextView18;

    @Override
    public int getLayoutId() {
        return R.layout.activity_notices_detail;
    }

    @Override
    public Object newP() {
        return null;
    }

    @Override
    public void initData(Bundle savedInstanceState) {
        mTitleBar.setListener((v, action, extra) -> finish());
        mTitleBar.getCenterTextView().setText("通知消息");
        getDetailData();
    }

    private void getDetailData() {
        HomeModel.getInstance().getNoticeDetail(_id, new SimpleCallBack<NoticeDetailEntity>() {
            @Override
            public void onSuccess(NoticeDetailEntity pDetailEntity) {
                mTextView11.setText(pDetailEntity.getName());
                mTextView17.setText(RxTimeTool.date2String(new Date(Long.parseLong(pDetailEntity.getUpdate_time()) * 1000)));
                RichText.initCacheDir(context);
                RichText.fromHtml(pDetailEntity.getDetail()).into(mTextView18);
            }
        });
    }
}
